#include "signaldata.h"

SignalData::SignalData() :data_points(), bounding(1.0,1.0,-1.0,-1.0)
{
	data_points.reserve(1024);
}
QPointF SignalData::sample(size_t i) const
{
	return data_points[i];
}
size_t SignalData::size() const
{
	return data_points.size();
}

QRectF SignalData::boundingRect() const
{
	return bounding;
}
void SignalData::addPoint(double x, double y)
{
	data_points.append(QPointF(x, y));
	if (bounding.width() < 0 || bounding.height() < 0)
	{
		bounding.setRect(x, y, 0.0, 0.0);
	}
	else
	{
		bounding.setRight(x);

		if (y > bounding.bottom()) 
			bounding.setBottom(y);

		if (y < bounding.top())
			bounding.setTop(y);
	}
}
SignalData::~SignalData()
{

}
